package com.tinama.jedis01.lock8;

import java.util.concurrent.TimeUnit;

/**
 * @author lgc
 * @createDate 2020/10/13 - 14:45
 */
public class Test1 {
    public static void main(String[] args){
        Phone phone = new Phone();
        Phone phone2 = new Phone();
        new Thread(()->{phone.sendMsg();},"A").start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
//        new Thread(()->{phone.call();},"B").start();
        new Thread(()->{phone2.call();},"B").start();
    }

}
class Phone{
    public static synchronized void sendMsg(){
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("发短信");
    }
    public synchronized void call(){
        System.out.println("打电话");
    }
    public void hello(){
        System.out.println("hello");
    }
}
